package com.lt.exam.ZhuangShiQi.ShiXian;

import com.lt.exam.Yao.Yao;
import com.lt.exam.Yao.YaoMap;
import com.lt.exam.ZhuangShiQi.BingLi;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author LT
 * @version 1.0
 * @PackageName com.lt.exam.ZhuangShiQi.Impl
 * @ClassName JiBenBingLi
 * @Description to do
 * @date 2021/12/1 16:11
 */
public class JiBenBingLi implements BingLi {
    private double price = 0.0;
    private String description = "病例内容为：";
    //存放药的数组
    List<Yao> yaoList = new ArrayList<Yao>(

    );

    public JiBenBingLi() {
        yaoList.add(YaoMap.getYaoMap().get("病例内容"));
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Yao> getYaoList() {
        return yaoList;
    }

    public void setYaoList(List<Yao> yaoList) {
        this.yaoList = yaoList;
    }

    @Override
    public double cost() {
        return price;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public List<Yao> getList() {
        return yaoList;
    }

    @Override
    public void add(Yao yao){
        if (yaoList.contains(yao)){
            System.out.println("该药品已存在");
        }else{
            yaoList.add(yao);
        }
    }
    @Override
    public void delete(Yao yao){
        if (yaoList.contains(yao)){
            yaoList.remove(yao);
        }else{
            System.out.println("该药品不存在，删除失败");
        }
    }

    @Override
    public void printList() {
        for (Yao yao :getList()){
            if (yao.getPrice() != 0.0) {
                System.out.println(yao);
            }
        }
    }
}
